using System.ComponentModel;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace iPhOwa.Web.Controls
{
	/// <summary>
	/// Renders a panel layer that can be clicked on anywhere.
	/// </summary>
	[ToolboxData("<{0}:ClickablePanel ID=\"ClickableDivID\" runat=\"server\"></{0}:ClickablePanel>")]
	public class ClickablePanel : Panel
	{
		/// <summary>
		/// The URL to link to.
		/// </summary>
		[Bindable(true)]
		[Category("Appearance")]
		[DefaultValue("")]
		[Description("The url to link to.")]
		public string Href
		{
			get { return (string)ViewState["Href"] ?? string.Empty; }
			set { ViewState["Href"] = value; }
		}

		///<summary>
		///Adds HTML attributes and styles that need to be rendered to the specified <see cref="T:System.Web.UI.HtmlTextWriterTag"></see>. This method is used primarily by control developers.
		///</summary>
		protected override void AddAttributesToRender(HtmlTextWriter writer)
		{
			base.AddAttributesToRender(writer);
			writer.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Format(CultureInfo.InvariantCulture, "window.location.href='{0}';", Href));
			writer.AddAttribute("onmouseover", "this.style.cursor='pointer';");
		}
	}
}